<template lang="pug">
  <div class="version">
    <h2>版本信息</h2>
    <hr/>
    <div class="version-detail" v-for="item in versionList">
      <div class="version-header">
        <h3>
          <a href="##"><b>{{item.name}}</b>  {{item.id}}</a>
        </h3>
        <span class="intro">{{item.intro}}</span>
        <br/>
        <span class="date">更新时间：{{item.date}}</span>
      </div>
      <ul class="version-desclist">
        <li v-for="desc in item.descList">{{desc}}</li>
      </ul>
    </div>
  </div>
</template>

<script>
export default {
  data () {
    return {
      versionList: []
    }
  },
  mounted () {
    this.$get({
      url: '/dxbase/version'
    }).then((filtered) => {
      let data = filtered.data
      for (let i = 0; i < data.length; i++) {
        var date = new Date(data[i].createTime)
        // 整理版本信息数据
        let versionInfo = {
          id: data[i].versionAlias,
          name: data[i].versionCode,
          date: date.getFullYear() + '-' + date.getMonth() + '-' + date.getDate() + ' ' + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds(),
          intro: data[i].introduce,
          descList: []
        }
        // 整理版本描述数据
        for (let j = 0; j < data[i].description.length; j++) {
          let descInfo = data[i].description[j]
          versionInfo.descList.push(descInfo)
        }
        this.versionList.push(versionInfo)
      }
    })
  }
}
</script>

<style lang="sass" scoped>
.version
  width: 90%
  height: 100%
  overflow: hidden
  padding-left: 30px
  h2
    text-align: center
    font-weight: 400
    margin-bottom: 50px
  .version-detail
    width: 100%
    border-bottom: 1px solid lightgray
    .version-header
      width: 100%
      height: 100%
      margin-bottom: 16px
      h3
        a
          color: #0366d6
          text-decoration: none
      span
        margin-left: 5px
        margin-bottom: 5px
      .date
        font-size: 14px
        font-weight: lighter
        color: #909399
      .intro
        font-size: 16px
        color: #586069
    .version-desclist
      list-style: disc outside none
      margin-bottom: 10px
      li
        list-style: disc outside none
        display: list-item
        margin-left: 2.5em
        color: #24292e
        font-size: 16px
        line-height: 1.8
</style>
